﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<WebMassage.Models.HomeViewModel>" %>

<%@ Import Namespace="WebMassage.Models" %>
<%@ Import Namespace="WebMassage.Helpers" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    ManagerHome
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <script src="<%= Url.Content("~/Scripts/jquery-1.4.1.js") %>" type="text/javascript"></script>
    <script src="../../Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script type="text/javascript">
        var i = 1;
        function GetPages() {
            $.get($(this).attr("href"), function (response) {
                $("#pages").replaceWith($("#pages", response));
            });
            return false;
        }

        $(function () {
            $("#lnkMoreUpload").live("click", function () {
                $("#divFiles").append('<div style="padding:4px;"><a href="#">Xóa</a> <input type="file" name="file' + i + '' + '" /></div>');
                i = i + 1;
            });

            $("#lnkMorePic").live("click", function () {
                var str = '<img  src="/Content/Images/IMG6.png" class="ktv" />';
                $("#divPics").append(str);
            });

            $(".ktv").live("click", function (e) {
                $('#ktvInfo').css('top', e.pageY);
                $('#ktvInfo').css('left', e.pageX);
                $('#ktvInfo').css('position', 'absolute');
                $('#ktvInfo').css('display', 'block');
                $('#field_ktvId').val($(this).attr('id'));
                $('#selectKTV').empty();

                $.getJSON('/KTV/GetKtvNotShow', function (data) {
                    $('#selectKTV').append('<option value="">' + 'Không hiển thị' + '</option>');
                    for (var i = 0; i < data.length; i++) {
                        $('#selectKTV').append('<option value="' + data[i].KTVNum + '">' + data[i].Name + '</option>');
                    }
                });
            });
        });

        function changeKTV() {

            $.get('/KTV/UpdateShowHome/?ktvNum=' + $('#selectKTV').val() + '&ktvId=' + $('#field_ktvId').val(), function (response) {
                $('#divPics').replaceWith(response);
            });
            $('#ktvInfo').css('display', 'none');
        }

    </script>
    <div style="padding: 10px;">
        <div id="uploads">
            <div style="width: 49%; float: left;">
                <div>
                    <%
                        if (Model.SlidePics != null)
                        {
                            int i = 0;
                            foreach (string img in Model.SlidePics)
                            { %>
                    <a href="">
                        <img id="slider<%= i + 1 %>" src="<%= img %>" alt="" style="margin-right:4px; border: 1px solid white;width:100px;height:100px" />
                    </a>
                    <%  
                        i++;
                            }
                        }
                    %>
                </div>
                <div id="sliderPics">
                    <% using (Html.BeginForm("UploadImage", "Home", FormMethod.Post, new { enctype = "multipart/form-data" }))
                       {%>
                    <div id="divFiles">
                        <div style="padding: 4px;">
                            <a href="#">Xóa</a>
                            <input type="file" name="file" id="fileUpload" />
                        </div>
                    </div>
                    <div style="padding: 5px">
                        <input type="submit" value="Cập nhật" />
                    </div>
                    <% } %>
                </div>
                <div>
                    <img id="lnkMoreUpload" class="more" src="/Content/Images/Black/MORE.png" alt="" />
                    </div>
            </div>
            <div style="width: 49%; float: left;">
                <div id="divPics">
                    <!-- Vung ky thuat vien-->
                    <%
                        foreach (KTVPic item in Model.KTVPics)
                        {
                            string str = "<img";
                            str += " src='" + item.PictureUrl + "'";
                            str += " id='" + item.KTVId + "'" ;                             
                            str += " class='ktv' style='margin-right:4px; border: 1px solid white;width:100px;height:100px'";
                            str += " alt='" + item.Note + "'";
                            str += " title='" + item.Note + "'";
                            str += " />";
                            Response.Write(str);
                        }
                    %>
                    <!-- Vung ky thuat vien -->
                </div>
                <div style="display: none">
                    <img id="lnkMorePic" class="more" src="/Content/Images/Black/MORE.png" alt="" /></div>
            </div>
            <input type="hidden" id="field_ktvId" value="" />
            <div id="ktvInfo" style="display:none;border: 1px solid white; ">
                <select id="selectKTV" onchange="changeKTV()">
                </select>
            </div>
        </div>
    </div>
</asp:Content>
